<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<title>核算项目--物料新增</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css"
			href="<%=request.getContextPath()%>/css/public.css">
		<link rel="stylesheet" type="text/css"
			href="<%=request.getContextPath()%>/css/baseset/moneykind_input.css">
		<script language="JavaScript"
			src="<%=request.getContextPath()%>/js/public.js"></script>
		<script language="JavaScript"
			src="<%=request.getContextPath()%>/js/validate.js"></script>
		<script language="JavaScript"
			src="<%=request.getContextPath()%>/js/date1.js"></script>

		<script type="text/javascript">
			/*
			 * 打开新窗口（汤云伟）
			 * link:链接地址
			 * name:窗口的名称
			 * width:窗口的宽度
			 * height:窗口的高度
			 * scroll:窗口是否有滚动条，1：有滚动条；0：没有滚动条
			 * id:约束参数
			 */
			function openWinT(link,name,width,height,scroll){
				var id = document.getElementById("groupId");
				if(id.value == ''){
					alert("计量单位组不能为空");
					return false ;
				}
				alert(id.value);
				var truelink = link+'?measureGroupId='+id.value;
				var sb = scroll == "1" ? "1" : "0";
				var l = (screen.width - width)/2;
				var t = (screen.height - height)/2;
				var sFeatures = "left="+ l +",top="+ t +",height="+ height +",width="+ width + ",center=1,scrollbars=" + sb + ",status=0,directories=0,channelmode=0";
				var openwin = window.open(truelink , name , sFeatures );
				if (!openwin.opener)
				{
					openwin.opener = self;
				}
				openwin.focus();
			}
			
			function multiSelectT(hiddenName,hiddenId,link,name,width,height,scroll){
				var id = document.getElementById("groupId");
				if(id.value == ''){
					alert("计量单位组不能为空");
					return false ;
				}
				var truelink = link+'?measureGroupId='+id.value;
			   	//得到隐藏在jsp页面上的会计科目name
			    var accountbookName = document.getElementById('measureUnitName');
			    
			    //如果参数hiddenId的值不为''是（jsp面上需要id属性）
			    if(hiddenId!=''){
					var accountbookId = document.getElementById('measureUnitId');
					accountbookId.value=hiddenId;
					accountbookName.value=hiddenName;
				}
				else//jsp页面上不需要id属性
					accountbookName.value=hiddenName;
					
				//打开多选会计科目的select页面
				openWin(truelink,name,width,height,scroll);
			}
			
			function validate(){
				var materialCode = document.getElementById("materialCode");
				var materialName = document.getElementById("materialName");
				var groupName = document.getElementById("groupName");
				var measureUnitName1 = document.getElementById("measureUnitName1");
				var measureUnitName2 = document.getElementById("measureUnitName2");
				var measureUnitName3 = document.getElementById("measureUnitName3");
				var measureUnitName4 = document.getElementById("measureUnitName4");
				
				var accountbookName1 = document.getElementById("accountbookName1");
				var accountbookName2 = document.getElementById("accountbookName2");
				var accountbookName3 = document.getElementById("accountbookName3");
				
				if (!isNotNull(materialCode,'物料代码'))
					return false;
				if (!f_check_NumOrLett(materialCode,'物料代码'))
					return false;
				if (!f_check_NumLength(materialCode,'物料代码'))
					return false;
				if (!isNotNull(materialName,'物料名称'))
					return false;
				if (!f_check_ZhOrNumOrLett(materialName,'物料名称'))
					return false;
				if (!f_check_passwordLength(materialName,'物料名称',1,25))
					return false;
					
				if (!isNotNull(groupName,'计量单位组'))
					return false;
				if (!isNotNull(measureUnitName1,'基本计量单位'))
					return false;
				if (!isNotNull(measureUnitName2,'采购计量单位'))
				return false;
				if (!isNotNull(measureUnitName3,'销售计量单位'))
				return false;
				if (!isNotNull(measureUnitName4,'库存计量单位'))
				return false;
				if (!isNotNull(accountbookName1,'存货科目代码'))
				return false;
				if (!isNotNull(accountbookName2,'销售收入科目代码'))
				return false;
				if (!isNotNull(accountbookName3,'销售成本科目代码'))
				return false;
				
				
				var numberPrecision = document.getElementById("numberPrecision");
				var bottomStorageNum = document.getElementById("bottomStorageNum");
				var topStorageNum = document.getElementById("topStorageNum");
				var securityStorageNum = document.getElementById("securityStorageNum");
				var guaranteePeriod = document.getElementById("guaranteePeriod");
				
				var stockPrice = document.getElementById("stockPrice");
				var salesPrice = document.getElementById("salesPrice");
				var planPrice = document.getElementById("planPrice");
				
				if (isNull(numberPrecision,'数量精度')){
					;
				}else if(!f_check_integer(numberPrecision,'数量精度')){
					return false;
				}
				if (isNull(bottomStorageNum,'最低存量')){
					;
				}else if(!f_check_integer(bottomStorageNum,'最低存量')){
					return false;
				}
				if (isNull(topStorageNum,'最高存量')){
					;
				}else if(!f_check_integer(topStorageNum,'最高存量')){
					return false;
				}
				if (isNull(securityStorageNum,'安全库存量')){
					;
				}else if(!f_check_integer(securityStorageNum,'安全库存量')){
					return false;
				}
				
				//if (isNull(guaranteePeriod,'保质期')){
				//	;
				//}else if(!f_check_integer(guaranteePeriod,'保质期')){
				//	return false;
				//}
				if (isNull(stockPrice,'采购单价')){
					;
				}else if(!f_check_float(stockPrice,'采购单价')){
					return false;
				}
				if (isNull(salesPrice,'销售单价')){
					;
				}else if(!f_check_float(salesPrice,'销售单价')){
					return false;
				}
				if (isNull(planPrice,'计划单价')){
					;
				}else if(!f_check_float(planPrice,'计划单价')){
					return false;
				}
			}
		</script>
		
	</head>

	<body>
		<div id="info_all" style="width: 610px;">
			<div id="info_top">
				核算项目--物料新增
			</div>
			<div style="width: 600px; margin-top: 6px;">
				<s:form action="editMaterial.action" method="post"
					theme="simple" onsubmit="return validate()">
					<table
						style="margin-top: 10px; background: #fbfbfb; color: #403040;"
						align="center">
						<tr>
							<td>
								代码*
							</td>
							<td>
								<s:hidden name="mdto.material.materialId" id="materialId"></s:hidden>
								<s:textfield name="mdto.material.materialCode" id="materialCode"
									size="15"></s:textfield>
							</td>
							<td>
								名称*
							</td>
							<td>
								<s:textfield name="mdto.material.materialName" id="materialName"
									size="15"></s:textfield>
							</td>
						</tr>
					</table>
					<table
						style="margin-top: 10px; background: #fbfbfb; color: #403040;"
						align="center">
						<tr
							style="height: 24px; font-weight: bold; text-align: center; font-size: 10pt;">
							<td colspan="2">
								基本资料
							</td>
							<td colspan="2">
								物流资料
							</td>
						</tr>

						<tr>
							<td>
							</td>
							<td>
							</td>

						</tr>
						<tr>
							<td>
								规格型号
							</td>
							<td>
								<s:textfield name="mdto.material.spec" id="spec" size="15"></s:textfield>
							</td>
							<td>
								采购负责人
							</td>
							<td>
								<s:hidden name="mdto.material.PBaseVerifyprojectCandiateId"
									id="candiateId"></s:hidden>
								<s:textfield name="mdto.candiate.candiateName" id="candiateName"
									readonly="true" size="15"></s:textfield>
								<img src="images/kookup.gif" style="cursor: pointer"
									onclick="openWin('selectCandiate.action','candiate',1050,700,0)">
							</td>
						</tr>
						<tr>
							<td>
								辅助属性类别
							</td>
							<td>
								<s:hidden
									name="mdto.material.PBaseMaterialAssistantattributetypeId"
									id="TypeId"></s:hidden>
								<s:textfield
									name="mdto.assistantattributetype.assistantAttributeTypeName"
									id="TypeName" readonly="true" size="15"></s:textfield>
								<img src="images/kookup.gif" style="cursor: pointer"
									onclick="openWin('attributeTypeSelect.action','assistantAttributeTypeName',400,300,0)">
							</td>
							<td>
								采购单价
							</td>
							<td>
								<s:textfield name="mdto.material.stockPrice" id="stockPrice"
									size="15"></s:textfield>
							</td>
						</tr>
						<tr>
							<td>
								物料属性
							</td>
							<td>
								<%--<s:textfield name="mdto.material.materialAttribute"
									id="materialAttribute" size="15"></s:textfield>
									--%>
								<s:if test="mdto.material.materialAttribute == '自制'">
									<s:select list="#{'自制':'自制','外购':'外购','其它':'其它'}" name="mdto.material.materialAttribute">
									</s:select>
								</s:if>
								<s:elseif test="mdto.material.materialAttribute == '外购'">
									<s:select list="#{'外购':'外购','其它':'其它','自制':'自制'}" name="mdto.material.materialAttribute">
									</s:select>
								</s:elseif>
								<s:elseif test="mdto.material.materialAttribute == '其它'">
									<s:select list="#{'其它':'其它','自制':'自制','外购':'外购'}" name="mdto.material.materialAttribute">
									</s:select>
								</s:elseif>
								<s:else>
									<s:select list="#{'自制':'自制','外购':'外购','其它':'其它'}" name="mdto.material.materialAttribute">
									</s:select>
								</s:else>
							</td>
							<td>
								销售单价
							</td>
							<td>
								<s:textfield name="mdto.material.salesPrice" id="salesPrice"
									size="15"></s:textfield>
							</td>
						</tr>
						<tr>
							<td>
								计量单位组*
							</td>
							<td>
								<s:hidden name="mdto.material.PBaseMeasuregroupId" id="groupId"></s:hidden>
								<s:textfield name="mdto.measureGroup.measureGroupName"
									id="groupName" readonly="true" size="15"></s:textfield>
								<img src="images/kookup.gif" style="cursor: pointer"
									onclick="openWin('selectMeasureGroup.action','measuerGroup',350,500,0)">
							</td>
							<td>
								计划单价
							</td>
							<td>
								<s:textfield name="mdto.material.planPrice" id="planPrice"
									size="15" size="15"></s:textfield>
							</td>
						</tr>
						<tr>
							<td>
								基本计量单位*
							</td>
							<td>
								<s:hidden id="measureUnitName"></s:hidden>
								<s:hidden id="measureUnitId"></s:hidden>
								<s:hidden name="measureUnit1" id="measureUnitId1"></s:hidden>
								<s:textfield name="mdto.material.basicMeasureUnit"
									id="measureUnitName1" readonly="true" size="15"></s:textfield>
								<img src="images/kookup.gif" style="cursor: pointer"
									onclick="multiSelectT('measureUnitName1','measureUnitId1','selectByGroupId.action','measureUnit',350,500,0)">
								
							</td>
							<td>
								存货科目代码*
							</td>
							<td>
								<s:hidden id="accountbookName"></s:hidden>
								<s:hidden id="accountbookId"></s:hidden>
								<s:hidden
									name="mdto.material.PBaseAccountbookByStorageAccountBookId"
									id="accountbookId1"></s:hidden>
								<s:textfield name="mdto.storageAccountBook.accountbookName"
									id="accountbookName1" size="15" readonly="true" size="15"></s:textfield>
								<img src="images/kookup.gif" style="cursor: pointer"
									onclick="multiSelect('accountbookName1','accountbookId1','selectMultiAccountbook.action','accountbook',750,700,0)">
							</td>
							<%--<td>
								保质期(天)(*)：
							</td>
							<td>
								<s:textfield name="mdto.material.guaranteePeriod"
									id="guaranteePeriod" size="15"></s:textfield>
							</td>
						--%>
						</tr>
						<tr>
							<td>
								采购计量单位*
							</td>
							<td>
								<s:hidden name="measureUnit2" id="measureUnitId2"></s:hidden>
								<s:textfield name="mdto.material.stockMeasureUnit"
									id="measureUnitName2" readonly="true" size="15"></s:textfield>
								<img src="images/kookup.gif" style="cursor: pointer"
									onclick="multiSelectT('measureUnitName2','measureUnitId2','selectByGroupId.action','measureUnit',350,500,0)">
							</td>
							<td>
								销售收入科目代码*
							</td>
							<td>
								<s:hidden
									name="mdto.material.PBaseAccountbookBySalesInputAccountBookId"
									id="accountbookId2"></s:hidden>
								<s:textfield name="mdto.salesInputAccountBook.accountbookName"
									id="accountbookName2" size="15" readonly="true" size="15"></s:textfield>
								<img src="images/kookup.gif" style="cursor: pointer"
									onclick="multiSelect('accountbookName2','accountbookId2','selectMultiAccountbook.action','accountbook',750,700,0)">
							</td>
						</tr>
						<tr>
							<td>
								销售计量单位*
							</td>
							<td>
								<s:hidden name="measureUnit3" id="measureUnitId3"></s:hidden>
								<s:textfield name="mdto.material.salesMeasureUnit"
									id="measureUnitName3" readonly="true" size="15"></s:textfield>
								<img src="images/kookup.gif" style="cursor: pointer"
									onclick="multiSelectT('measureUnitName3','measureUnitId3','selectByGroupId.action','measureUnit',350,500,0)">
							</td>
							<td>
								销售成本科目代码*
							</td>
							<td>
								<s:hidden
									name="mdto.material.PBaseAccountbookBySalesCostAccountBookId"
									id="accountbookId3"></s:hidden>
								<s:textfield name="mdto.salesCostAccountBook.accountbookName"
									id="accountbookName3" size="15" readonly="true" size="15"></s:textfield>
								<img src="images/kookup.gif" style="cursor: pointer"
									onclick="multiSelect('accountbookName3','accountbookId3','selectMultiAccountbook.action','accountbook',750,700,0)">
							</td>
						</tr>
						<tr>
							<td>
								库存计量单位*
							</td>
							<td>
								<s:hidden name="measureUnit4" id="measureUnitId4"></s:hidden>
								<s:textfield name="mdto.material.storageMeasureUnit"
									id="measureUnitName4" readonly="true" size="15"></s:textfield>
								<img src="images/kookup.gif" style="cursor: pointer"
									onclick="multiSelectT('measureUnitName4','measureUnitId4','selectByGroupId.action','measureUnit',350,500,0)">
							</td>
							
						</tr>
						<tr>
							<td>
								默认仓库
							</td>
							<td>
								<s:hidden name="mdto.material.PBaseVerifyprojectStorageId"
									id="storageId"></s:hidden>
								<s:textfield name="mdto.storage.storageName" id="storageName"
									size="15" readonly="true" size="15"></s:textfield>
								<img src="images/kookup.gif" style="cursor: pointer"
									onclick="openWin('selectStorage.action','storage',1050,700,0)">
							</td>
							<td>
							</td>
							<td>
							</td>
						</tr>
						<tr>
							<td>
								来源(供应商)
							</td>
							<td>
								<s:hidden name="mdto.material.PBaseVerifyprojectSupplierId"
									id="supplierId"></s:hidden>
								<s:textfield name="mdto.supplier.supplierName" id="supplierName"
									size="15" readonly="true" size="15"></s:textfield>
								<img src="images/kookup.gif" style="cursor: pointer"
									onclick="openWin('supplierSelect.action','supplier',1050,700,0)">
							</td>
							<td>
							</td>
							<td>
							</td>
						</tr>
						<tr>
							<td>
								数量精度
							</td>
							<td>
								<s:textfield name="mdto.material.numberPrecision"
									id="numberPrecision" size="15" size="15"></s:textfield>
							</td>
							<td>
							</td>
							<td>
							</td>
						</tr>
						<tr>
							<td>
								最低存量
							</td>
							<td>
								<s:textfield name="mdto.material.bottomStorageNum"
									id="bottomStorageNum" size="15" size="15"></s:textfield>
							</td>
							<td>
							</td>
							<td>
							</td>
						</tr>
						<tr>
							<td>
								最高存量
							</td>
							<td>
								<s:textfield name="mdto.material.topStorageNum"
									id="topStorageNum" size="15" size="15"></s:textfield>
							</td>
							<td>
							</td>
							<td>
							</td>
						</tr>
						<tr>
							<td>
								安全库存数量
							</td>
							<td>
								<s:textfield name="mdto.material.securityStorageNum"
									id="securityStorageNum" size="15" size="15"></s:textfield>
							</td>
							<td>
							</td>
							<td>
							</td>
						</tr>
						<tr>
							<td>
								备注
							</td>
							<td>
								<s:textfield name="mdto.material.memo" id="memo" size="15"
									size="15"></s:textfield>
							</td>
							<td>
							</td>
							<td>
							</td>
						</tr>
						<tr>
							<td colspan="2">
								<div style="margin: 6px; text-align: right;">
									<input type="submit" value="保存" onFocus="this.blur()"
										onMouseOver="this.className='btnover'"
										onmouseout="this.className='btnout'" class="btnsize" />
								</div>
							</td>
							<td>
								<div style="margin: 6px; text-align: right;">
									<input type="button" value="返回"
										onclick="javascript:history.go(-1)" onFocus="this.blur()"
										onMouseOver="this.className='btnover'"
										onmouseout="this.className='btnout'" class="btnsize" />
								</div>
							</td>
							<td></td>
						</tr>
					</table>
				</s:form>
			</div>
			
		</div>
	</body>
</html>
